﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using YXChatFormClient.Dtos.Buddy;
using YXChatFormClient.Utility;

namespace YXChatFormClient.UserControls
{
    public partial class UC_BuddyItem : UserControl
    {
        public UC_BuddyItem()
        {
            InitializeComponent();
            //设置控件样式
            SetStyle(
                    ControlStyles.AllPaintingInWmPaint | //不闪烁
                    ControlStyles.OptimizedDoubleBuffer //支持双缓存
                    , true);
        }
        public delegate void BuddyClickHandler(BuddyAccountOutput buddyAccountOutput);
        public event BuddyClickHandler BuddyClick;
        public BuddyAccountOutput BuddyAccountOutput { get; set; }
        private void UC_BuddyItem_Click(object sender, EventArgs e)
        {
            foreach (Control itemControl in this.Parent.Controls)
            {
                itemControl.BackColor = Color.Gainsboro;
            }
            this.BackColor = Color.FromArgb(198, 198, 198);
            if (BuddyClick != null) BuddyClick(BuddyAccountOutput);
        }

        private void UC_BuddyItem_Load(object sender, EventArgs e)
        {
            this.lbBuddyRemark.Text = BuddyAccountOutput.Account.NickName;
            this.picAvatar.ImageLocation = ImageHelper.GetServerImage(BuddyAccountOutput.Account.Avatar);
        }
    }
}
